//
// Created by Jisam on 2024/8/18 21:09.
// Solution of  不是烤串故事 
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define code_by_jisam ios::sync_with_stdio(false),cin.tie(nullptr)
using namespace std;
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;

const int N = 1e6 + 5, M = 2e6 + 5;

char a[N], b[N], s[M];
int z[M];
int f[N];

void solution() {
    // 初始化变量n，a，b，从输入流读取n，a，b的值
    int n;
    cin >> n >> a >> b;

    // 将b数组的元素复制到s数组的前n个位置
    for (int i = 0; i < n; i++) {
        s[i] = b[i];
    }

    // 将a数组的元素逆序复制到s数组的后n个位置
    for (int i = 0; i < n; i++) {
        s[i + n] = a[n - 1 - i];
    }

    // Z算法，用于找出s中与s的前缀匹配的最长后缀
    for (int i = 1, j = 1; i < n << 1; i++) {
        z[i] = 0;
        if (i < j + z[j]) z[i] = min(z[i - j], j + z[j] - i);
        while (i + z[i] < n << 1 && s[i + z[i]] == s[z[i]]) {
            z[i]++;
        }
        if (i + z[i] > j + z[j]) j = i;
    }

    // 初始化f数组，用于记录a和b相同元素的连续长度
    f[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == b[i]) f[i] = f[i + 1] + 1;
        else f[i] = 0;
    }

    // 寻找s中与s的前缀匹配的最长后缀，并记录其长度和起始位置
    int ret = 0, idx = 1;
    for (int i = 0; i < n; i++) {
        int t = z[2 * n - 1 - i];
        if (t >= i + 1) t = i + 1 + f[i + 1];
        if (t > ret) {
            ret = t;
            idx = i + 1;
        }
    }

    // 输出结果：匹配的最长后缀的长度和起始位置
    cout << ret << ' ' << idx << '\n';
}

int main() {
    code_by_jisam;
    int T = 1;
//    cin >> T;
    while (T--) {
        solution();
    }
    return 0;
}